package com.aoxin.controller.course.systemCourse;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aoxin.model.course.SlfOrderCourse;
import com.aoxin.service.inter.course.systemCourse.OrderCourseService;
import com.aoxin.util.AjaxRes;
import com.aoxin.util.Const;

/**
 * 预约 OrderCourse
 * 
 * @author Melody
 * @date 2018年3月27日 下午2:56:36
 */
@Controller
@ResponseBody
@RequestMapping("/web/orderCourse")
public class OrderCourseController {

	@Autowired
	private OrderCourseService orderCourseService;

	/**
	 * 添加预约
	 * 
	 * @param orderCourse
	 *            预约
	 */
	@RequestMapping("/insertOrderCourse")
	public AjaxRes insertOrderCourse(SlfOrderCourse orderCourse, AjaxRes ajaxRes) {
		try {
			this.orderCourseService.insertOrderCourse(orderCourse);
			ajaxRes.setSucceedMsg(Const.SAVE_SUCCEED);
		} catch (Exception e) {
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}

	/**
	 * 批量删除预约
	 * 
	 * @param orderCourseIds
	 *            预约ID集合
	 */
	@RequestMapping("/deleteOrderCourses")
	public AjaxRes deleteOrderCourses(@RequestParam("orderCourseIds") List<Integer> orderCourseIds, AjaxRes ajaxRes) {
		try {
			this.orderCourseService.deleteOrderCourses(orderCourseIds);
			ajaxRes.setSucceedMsg(Const.DEL_SUCCEED);
		} catch (Exception e) {
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}

	/**
	 * 修改预约
	 * 
	 * @param orderCourse
	 *            预约
	 */
	@RequestMapping("/updateOrderCourse")
	public AjaxRes updateOrderCourse(SlfOrderCourse orderCourse, AjaxRes ajaxRes) {
		try {
			this.orderCourseService.updateOrderCourse(orderCourse);
			ajaxRes.setSucceedMsg(Const.UPDATE_SUCCEED);
		} catch (Exception e) {
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}

	/**
	 * 查询预约
	 * 
	 * @param orderCourseId
	 *            预约ID
	 */
	@RequestMapping("/getOrderCourse")
	public AjaxRes getOrderCourse(@RequestParam("orderCourseId") Integer orderCourseId, AjaxRes ajaxRes) {
		try {
			SlfOrderCourse slfOrderCourse = this.orderCourseService.getOrderCourse(orderCourseId);
			ajaxRes.setSucceed(slfOrderCourse, Const.DATA_SUCCEED);
		} catch (Exception e) {
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}

	/**
	 * 查询预约
	 * 
	 * @param orderCourseId
	 *            预约ID
	 */
	@RequestMapping("/getOrderCourseList")
	public AjaxRes getOrderCourseList(@RequestParam Map<String, Object> map, AjaxRes ajaxRes) {
		try {
			List<SlfOrderCourse> slfOrderCourse = this.orderCourseService.getOrderCourseList(map);
			ajaxRes.setSucceed(slfOrderCourse, Const.DATA_SUCCEED);
		} catch (Exception e) {
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}
}
